package com.mars.tukuan.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mars.base.common.base.BaseController;
import com.mars.base.common.base.BaseResult;
import com.mars.base.common.exception.AppException;
import com.mars.base.common.utils.Paginator;
import com.mars.tukuan.dto.CarRepairVo;
import com.mars.tukuan.rpc.api.CarRepairService;

@RestController
@RequestMapping("/api/tukuan/car/repair")
public class CarRepairController extends BaseController {

	@Autowired
	private CarRepairService service;
	
	@PostMapping(value = "/saveOrUpdate")
	public Object addOrModify(@RequestBody CarRepairVo vo) {
		try {
			this.service.saveOrUpdate(vo);
		} catch (Exception e) {
			return BaseResult.addFailed();
		}
		return BaseResult.addOk();
	}
	
	
	@GetMapping(value = "/list")
	public Object list(CarRepairVo vo) {
		try {
			return  this.service.selectPageByCar(new Paginator(request), vo) ;
		} catch (AppException e) {
			return BaseResult.loadFailed();
		}
	}
}
